# 异常处理
# NameError
try:
    a = int(input("请输入一个数字"))
    num = 5 / a
    print(num)
except ZeroDivisionError as e:
    print('除数不能为零', e)
else:  # 没有被except捕获，执行else模块
    print('else')
finally:  # 无论有没有报错都要执行
    print('finally')

# raise 抛出一个异常 像Java中的throw
try:
    pwd = input('请输入您的密码')
    if len(pwd) < 8:
        raise Exception('密码长度不足,请重新输入')
except Exception as e:
    print(e)
